package _14作业.t1;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class Demo2 {
    public static void main(String[] args) {
        HashMap<String,String> map=new HashMap<>();
        map.put("张飞","18");
        map.put("刘备","21");
        map.put("关羽","22");

        //迭代器遍历
        Set<String> keySet = map.keySet();
        Iterator<String> iterator = keySet.iterator();
        while (iterator.hasNext()){
            String key = iterator.next();
            System.out.println(key+"="+map.get(key));
        }
        System.out.println("=============================");
        //增强for遍历
        for (String s : keySet) {
            System.out.println(s+"="+map.get(s));
            
        }
    }
}
